﻿using LD.Tool;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using YTE.Control;

namespace LD.Host
{
    public partial class FrmOutputBind : FrmOKCancel
    {
        public FrmOutputBind()
        {
            InitializeComponent();
            this.btn_ok.Click += Btn_ok_Click;
            this.treeView1.ExpandAll();
        }
        public string BindOutput { get; private set; }
        private void Btn_ok_Click(object sender, EventArgs e)
        {
            var selectNode = this.treeView1.SelectedNode;
            if (selectNode != null)
            {
                BindOutput = selectNode.FullPath;
            }
        }

        public FrmOutputBind(string flowName, Type type) : this()
        {
            var flow = Appbus.PartNo.Config.Flow.Where(p => p.Name == flowName).FirstOrDefault();
            foreach (var item in flow.Tools)
            {
                if (item.OutPut != null)
                {
                    //父系
                    TreeNode node = new TreeNode();
                    node.Text = item.Name;
                    foreach (var outObj in item.OutPut)
                    {
                        TreeNode c_node = new TreeNode();
                        c_node.Text = outObj.Key;
                        node.Nodes.Add(c_node);
                        //if (type.GetType() == outObj.Value.GetType())
                        //{
                        //}
                    }
                    this.treeView1.Nodes.Add(node);
                }
            }
        }
    }
}
